#!/bin/sh
sed -i ":a;$!N;s/tmpl.render.*sysauth_template.*return/local scope = { duser = default_user, fuser = user }\nlocal ok, res = luci.util.copcall\(luci.template.render_string, [[<% include\(\"themes\/\" .. theme .. \"\/sysauth\"\) %>]], scope\)\nif ok then\nreturn res\nend\nreturn luci.template.render\(\"sysauth\", scope\)/;ba" /usr/lib/lua/luci/dispatcher.lua
sed -i ":a;$!N;s/t.render.*sysauth_template.*return/local scope = { duser = h, fuser = a }\nlocal ok, res = luci.util.copcall\(luci.template.render_string, [[<% include\(\"themes\/\" .. theme .. \"\/sysauth\"\) %>]], scope\)\nif ok then\nreturn res\nend\nreturn luci.template.render\(\"sysauth\", scope\)/;ba" /usr/lib/lua/luci/dispatcher.lua
[ -f /usr/lib/lua/luci/view/themes/argon/out_header_login.htm ] && mv -f /usr/lib/lua/luci/view/themes/argon/out_header_login.htm /usr/lib/lua/luci/view/header_login.htm
rm -Rf /var/luci-modulecache
rm -Rf /var/luci-indexcache
uci batch <<-EOF
	set luci.themes.Argon=/luci-static/argon
	set luci.main.mediaurlbase=/luci-static/argon
	set luci.themes.Argon_Lean=/luci-static/argon_lean
	set luci.themes.Argon_Light=/luci-static/argon_light
	set luci.themes.Argon_Light_Green=/luci-static/argon_light_green
	set luci.themes.Argon_Dark=/luci-static/argon_dark
	set luci.themes.Argon_Dark_Purple=/luci-static/argon_dark_purple
	set luci.themes.Argon_Red=/luci-static/argon_red
	set luci.themes.Argon_ArmyGreen=/luci-static/argon_armygreen
	commit luci
EOF
exit 0